<?php
namespace jy_shoufrom;
defined('BY_JYA') or exit('error');
/*
*/
class notice extends \plugin{
	public function gettpl_data($orderid,$type=0){//type=0表单订单，type=1
		return false;
	}
	/*
		师傅新任务通知
	*/
	public function notice_fuwuorder($order=array()){
		//新师傅任务通知给师傅
		$basic=$this->plugin_setting('basic');
		if(!$basic['mid']){
			return false;
		}
		$order['serve_title']=pdo_getcolumn('jy_shoufrom_list',array('id'=>$order['pid'],'uniacid'=>$_SESSION['uniacid']),'title');
		$template_id=cfc('account')->get_tpl_template_id('OPENTM416739152','新任务通知');
		if($_SESSION['wxapp_id']){
			$wxapptemplate_id=cfc('wxapp_api')->get_tpl_template_id('17468',[1,2,3,7],'fuwuorder','新任务通知','jy_shoufrom');
		}
		$message=array(
			'first'=>array('value'=>'新任务通知',"color" => "#4a5077"),
			'keyword1'=>array('value'=>$order['ordersn'],"color" => "#4a5077"),
			'keyword2'=>array('value'=>date('Y/m/d H:i:s',$order['createtime']),"color" => "#4a5077"),
			'keyword3'=>array('value'=>'【报修】'.$order['serve_title'],"color" => "#4a5077"),
			'keyword4'=>array('value'=>$order['address'],"color" => "#4a5077"),
			'remark'=>array('value'=>'您有新的订单！请及时处理！点击“详情”查看订单信息。',"color" => "#4a5077"),
		);
		$wxappmsg=array(
			array('value'=>$order['ordersn']),
			array('value'=>date('Y/m/d H:i:s',$order['createtime'])),
			array('value'=>$order['serve_title']),
			array('value'=>$order['address']),
		);
		if(!$url){
			$url=custom_url('jy_shoufrom/fuwu.order/detail/id='.$order['id'],true);	
		}
		if(method_exists(cfc('account'),'sendtwoNotice')){
			cfc('account')->sendtwoNotice($basic['mid'],$template_id,$message,$url,'fuwuorder','jy_shoufrom',$order_id);
		}
		if($_SESSION['wxapp_id']){
			$url='/jy_shoufrom/fuwu.order/detail/index?id='.$order['id'];
			$template_id=cfc('wxapp_api')->checktplNotice($basic['mid'],$wxapptemplate_id,$wxappmsg,$url,'fuwuorder','jy_shoufrom',$order_id);
		}
	}
}